(function() {
  var BaseConfig, ImportFiles, WebConfig, formatDate, viewContentHandler, _;

  _ = require('underscore');

  ImportFiles = require('../../../helpers/import_files');

  BaseConfig = require('../../../helpers/base_config');

  WebConfig = require('./web_config');

  viewContentHandler = {
    /**
     * [home description]
     * @param  {[type]} req      [description]
     * @param  {[type]} view     [description]
     * @param  {[type]} title    [description]
     * @param  {[type]} navIndex [description]
     * @param  {[type]} data     [description]
     * @return {[type]}          [description]
    */

    home: function(req, view, title, navIndex, data) {
      var articleListDialog, articlesContent, renderData, welcomeDialog;
      welcomeDialog = BaseConfig.getDialogConfig({
        selfId: 'welcomeDialog',
        title: '个人感言',
        data: data.welcomeDialogContent
      });
      articlesContent = data.articlesContent;
      _.each(articlesContent, function(articleContent) {
        return articleContent.date = formatDate(articleContent.createTime);
      });
      articleListDialog = BaseConfig.getDialogConfig({
        selfId: 'articleList',
        title: '文章分享',
        data: articlesContent
      });
      renderData = {
        title: title || '',
        importObj: ImportFiles.getImportObj(view),
        header: WebConfig.getHeader(navIndex || 0),
        viewContent: {
          welcomeDialog: welcomeDialog,
          articleListDialog: articleListDialog
        }
      };
      return renderData;
    }
  };

  /**
   * [formatDate description]
   * @param  {[type]} createTime [description]
   * @return {[type]}            [description]
  */


  formatDate = function(createTime) {
    var day, month;
    month = createTime.getMonth() + 1;
    day = createTime.getDate();
    if (month < 10) {
      month = '0' + month;
    }
    if (day < 10) {
      day = '0' + day;
    }
    return {
      month: month,
      day: day
    };
  };

  module.exports = viewContentHandler;

}).call(this);
